import { CreateStorage } from "./cache"

function ls() {
  return CreateStorage ( localStorage )
}

function ss() {
  return CreateStorage ( sessionStorage )
}

export class Cache {
  static getLocal(key: string) {
    return ls().get( key )
  }

  static setLocal( key: string, value: any ) {
    ls().set( key, value )
  }

  static removeLocal( key: string ) {
    ls().remove( key )
  }

  static clearLocal(  ) {
    ls().clear()
  }

  static getSession( key: string ) {
    return ss().get( key )
  }

  static setSession( key: string, value: any) {
    ss().set( key, value )
  }

  static removeSession( key: string ) {
    ss().remove( key )
  }

  static clearSession() {
    ss().clear()
  }

  static clearAll() {
    ls().clear()
    ss().clear()
  }

}
